package proxy.java;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JdkHandler implements InvocationHandler {
    Object originalObj;

    public JdkHandler(Object originalObj) {
        this.originalObj = originalObj;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        method.invoke(originalObj, args);
        after();
        return null;
    }

    private void before() {
        System.out.println("欢迎光临，请坐，请喝茶!(JDK dynamic)");
    }

    private void after() {
        System.out.println("多谢惠顾！(JDK dynamic)");
    }
}
